export const optionLineBar = (titlesText, types, datas) => {
    return {
        title: { text: titlesText },
        tooltip: {},
        xAxis: {
            data: datas.xAxis
        },
        yAxis: {},
        series: [
            {
                name: "销量",
                type: types,
                data: datas.data
            }
        ]
    }
}



var labelTop = {
    normal: {
        label: {
            show: true,
            position: 'center',
            formatter: '{b}',
            textStyle: {
                baseline: 'bottom',
                fontSize: 14,
            }
        },
        labelLine: {
            show: false
        }
    }
};
var labelFromatter = {
    normal: {
        label: {
            formatter: function (params) {
                return 100 - params.value + '%'
            },
            textStyle: {
                baseline: 'top',
                fontSize: 14,
            }
        }
    },
}
var labelBottom = {
    normal: {
        color: 'rgba(0,0,0,0.1)',
        label: {
            show: true,
            position: 'center'
        },
        labelLine: {
            show: false
        }
    },
    emphasis: {
        color: 'rgba(0,0,0,0.1)'
    }
};
export const optionPie = (titlesText, datas) => {
    return {
        tooltip: {
            show:false,
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        legend: {
            // orient: 'vertical',
            show: false,
            width: "100%",
            bottom: 30,
            data: datas.legend
        },
        series: [
            {
                name: titlesText,
                type: 'pie',
                radius: ['50%', '75%'],
                center: ["50%", "50%"],
                color: datas.color,
                avoidLabelOverlap: false,
                hoverAnimation:false,
                label: {
                    show: true,
                    position: 'center',
                    fontSize: '14',
                    formatter: (value)=>{
                        return value.name!='其他'?(value.value+'\n'+value.name):''
                    }
                },
                emphasis: {
                    label: {
                        show: false,
                        fontSize: '18',
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: datas.data
            },
        ]
    };
}




export const optionPies = () => {
    var radius = [40, 55];
    return {
        legend: {
            show: false,
        },
        title: {
            text: '各项工作占比',
            subtext: '原始数据来自测试组',
            x: 'center'
        },
        series: [
            {
                type: 'pie',
                center: ['10%', '30%'],
                radius: radius,
                x: '0%', // for funnel
                itemStyle: labelFromatter,
                data: [
                    { name: 'other', value: 75, itemStyle: labelBottom },
                    { name: '未过评审', value: 25, itemStyle: labelTop }
                ]
            },
            {
                type: 'pie',
                center: ['30%', '30%'],
                radius: radius,
                x: '20%', // for funnel
                itemStyle: labelFromatter,
                data: [
                    { name: 'other', value: 76, itemStyle: labelBottom },
                    { name: '已变更项目', value: 24, itemStyle: labelTop }
                ]
            },
            {
                type: 'pie',
                center: ['50%', '30%'],
                radius: radius,
                x: '40%', // for funnel
                itemStyle: labelFromatter,
                data: [
                    { name: 'other', value: 86, itemStyle: labelBottom },
                    { name: '超期项目', value: 14, itemStyle: labelTop }
                ]
            },
            {
                type: 'pie',
                center: ['70%', '30%'],
                radius: radius,
                x: '60%', // for funnel
                itemStyle: labelFromatter,
                data: [
                    { name: 'other', value: 89, itemStyle: labelBottom },
                    { name: '未交周报', value: 11, itemStyle: labelTop }
                ]
            },
            {
                type: 'pie',
                center: ['90%', '30%'],
                radius: radius,
                x: '80%', // for funnel
                itemStyle: labelFromatter,
                data: [
                    { name: 'other', value: 73, itemStyle: labelBottom },
                    { name: '未交月报', value: 27, itemStyle: labelTop }
                ]
            },
        ]
    };
}

export default { optionLineBar, optionPie, optionPies }